package com.kbp.model;

import java.util.Date;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.persistence.OneToMany;
import javax.persistence.JoinColumn;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

@Entity
@Table(name="user")
public class User implements java.io.Serializable{
	
	private static final long serialVersionUID = 1L;
	@Id
	@Column(name="USER_ID")
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	private Long id;
	@Column(name = "PREFIX")
	private String prefix;
	@Column(name = "NAME")
	private String name;
	@Column(name = "SURNAME")
	private String surname;
	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "DATE_OF_BIRTH")
	private Date dateOfBirth;
	@Column(name = "CODE" ,length = 13,nullable = false,unique = true)
	private String code; //  identification code 
	
	@Column(name = "CREATE_DATE")
	@Temporal(TemporalType.TIMESTAMP)
	private Date createDate = new Date();
	@Column(name = "UPDATE_DATE")
	@Temporal(TemporalType.TIMESTAMP)
	private Date updateDate;
	@Column(name = "PASSWD")
	private String passwd;
	@Column(name="ACCOUNT")
	private String account;
	@Column(name="BANK")
	private String bank;
	@Column(name = "BRANCE")
	private String branch;
	@Column(name="ACCOUNT_NUMBER")
	private String accNum;
	@Column(name = "OCCUPATION")
	private String occupation;
	@Column(name = "HOME_TEL")
	private String home_tel = "";
	@Column(name = "OFFICE_TEL")
	private String office_tel = "";
	@Column(name = "MOBILE")
	private String mobile = "";
	@Column(name = "FAX")
	private String fax = "";
	
	public String getOccupation() {
		return occupation;
	}
	public void setOccupation(String occupation) {
		this.occupation = occupation;
	}
	public String getHome_tel() {
		return home_tel;
	}
	public void setHome_tel(String home_tel) {
		this.home_tel = home_tel;
	}
	public String getOffice_tel() {
		return office_tel;
	}
	public void setOffice_tel(String office_tel) {
		this.office_tel = office_tel;
	}
	public String getMobile() {
		return mobile;
	}
	public void setMobile(String mobile) {
		this.mobile = mobile;
	}
	public String getFax() {
		return fax;
	}
	public void setFax(String fax) {
		this.fax = fax;
	}
	public String getAccount() {
		return account;
	}
	public void setAccount(String account) {
		this.account = account;
	}
	public String getBank() {
		return bank;
	}
	public void setBank(String bank) {
		this.bank = bank;
	}
	public String getBranch() {
		return branch;
	}
	public void setBranch(String branch) {
		this.branch = branch;
	}
	public String getAccNum() {
		return accNum;
	}
	public void setAccNum(String accNum) {
		this.accNum = accNum;
	}
	@OneToOne
	@JoinColumn(name="NODE1" , referencedColumnName = "ID")
	private Node1 node;
	
	private Set<Authorities> authorities=new HashSet<Authorities>();
	public void setAuthorities(Set<Authorities> authorities) {
		this.authorities = authorities;
	}
	
	@JoinColumn(nullable=true)
	@OneToMany(mappedBy = "AUTH_ID", cascade = {CascadeType.PERSIST,CascadeType.REMOVE,CascadeType.MERGE})
	public Set<Authorities> getAuthorities() {
		return authorities;
	}
	
	private Set<Detail> details = new HashSet<Detail>();
	public void setDetails(Set<Detail> details) {
		this.details = details;
	}
	
	@JoinColumn(nullable=true)
	@OneToMany(mappedBy = "ID", cascade = {CascadeType.PERSIST,CascadeType.REMOVE,CascadeType.MERGE})
	public Set<Detail> getDetails() {
		return details;
	}	
	
	public Long getId() {
		return id;
	}
	public void setId(Long id) {
		this.id = id;
	}
	public String getPrefix() {
		return prefix;
	}
	public void setPrefix(String prefix) {
		this.prefix = prefix;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public String getSurname() {
		return surname;
	}
	public void setSurname(String surname) {
		this.surname = surname;
	}
	public Date getDateOfBirth() {
		return dateOfBirth;
	}
	public void setDateOfBirth(Date dateOfBirth) {
		this.dateOfBirth = dateOfBirth;
	}
	public String getCode() {
		return code;
	}
	public void setCode(String code) {
		this.code = code;
	}
	public Date getCreateDate() {
		return createDate;
	}
	public void setCreateDate(Date createDate) {
		this.createDate = createDate;
	}
	public Date getUpdateDate() {
		return updateDate;
	}
	public void setUpdateDate(Date updateDate) {
		this.updateDate = updateDate;
	}
	public void setPasswd(String passwd) {
		this.passwd = passwd;
	}
	public String getPasswd() {
		return passwd;
	}
	public void setNode(Node1 node) {
		this.node = node;
	}
	public Node1 getNode() {
		return node;
	}
}